package com.cn.jdia.dc.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cn.jdia.dc.model.TopoInstance;
import com.cn.jdia.dc.service.ITopoInstanceService;

@Controller
public class TopoBrowserController {

	@Resource
	private ITopoInstanceService topoInstanceService;
	
	@RequestMapping(value = "/topobrowser")
	@ResponseBody
	public ModelAndView topoBrowser() {
		ModelAndView mav = new ModelAndView();
		mav.setViewName("topobrowser");
		
		List<String> proList = new ArrayList<>();
		List<TopoInstance> topoList = topoInstanceService.queryAllTopoInstance();
		for (TopoInstance instance : topoList) {
			proList.add(instance.getProject());
		}
		
		mav.addObject("list", proList);
		
		return mav;
	}
}
